package com.qmx.qmxapp.activity;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.text.format.Formatter;
import android.util.Log;
import android.view.GestureDetector;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.zhouwei.library.CustomPopWindow;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Progress;
import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.base.Request;
import com.qmx.qmxapp.R;
import com.qmx.qmxapp.base.BaseActivity;
import com.qmx.qmxapp.bean.Command;
import com.qmx.qmxapp.bean.DrawBoardAction;
import com.qmx.qmxapp.bean.DrawBoardData;
import com.qmx.qmxapp.bean.DrawBoardPoint;
import com.qmx.qmxapp.bean.LzyResponse;
import com.qmx.qmxapp.bean.RoomTipsInfo;
import com.qmx.qmxapp.bean.SelectColor;
import com.qmx.qmxapp.bean.StrokeWidth;
import com.qmx.qmxapp.callback.CGlideImageLoader;
import com.qmx.qmxapp.callback.JsonCallback;
import com.qmx.qmxapp.constant.AppConstant;
import com.qmx.qmxapp.constant.ComParamContact;
import com.qmx.qmxapp.constant.EventConfig;
import com.qmx.qmxapp.event.BoardEvent;
import com.qmx.qmxapp.fragment.ContactsFragment;
import com.qmx.qmxapp.fragment.CopyLinkFragment;
import com.qmx.qmxapp.fragment.HandsupFragment;
import com.qmx.qmxapp.fragment.InitiationFragment;
import com.qmx.qmxapp.fragment.RecentCallFragment;
import com.qmx.qmxapp.token.TokenManager;
import com.qmx.qmxapp.utils.DensityUtils;
import com.qmx.qmxapp.utils.SocketUtil;
import com.qmx.qmxapp.view.CustomScrollViewPager;
import com.qmx.qmxapp.view.DlgMgr;
import com.qmx.qmxapp.view.SketchpadView;
import com.tencent.av.sdk.AVRoomMulti;
import com.tencent.ilivesdk.ILiveConstants;
import com.tencent.ilivesdk.ILiveSDK;
import com.tencent.ilivesdk.core.ILiveRoomManager;
import com.tencent.ilivesdk.core.ILiveRoomOption;
import com.tencent.ilivesdk.listener.ILiveEventHandler;
import com.tencent.ilivesdk.tools.quality.ILiveQualityData;
import com.tencent.ilivesdk.view.AVRootView;
import com.tencent.ilivesdk.view.AVVideoView;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;

import net.lucode.hackware.magicindicator.MagicIndicator;
import net.lucode.hackware.magicindicator.ViewPagerHelper;
import net.lucode.hackware.magicindicator.buildins.UIUtil;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.json.JSONObject;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;

import io.realm.Realm;


/**
 * Created by tencent on 2018/5/21.
 */
public class RoomActivity extends BaseActivity implements View.OnClickListener, ILiveRoomOption.onExceptionListener, ILiveRoomOption.onRoomDisconnectListener,
        InitiationFragment.SendMessageCommunitor, HandsupFragment.HandsupMessage, SocketUtil.SocketDataCallback, RadioGroup.OnCheckedChangeListener, SketchpadView.ShowToolsbar {
    private final static String TAG = "RoomActivity";
    private AVRootView avRootView;
    private TextView tvRoomId;
    private ImageView ivSwitch, ivBeauty, ivMic, iv_hang_up;
    private LinearLayout ll_control;
    private RelativeLayout rl_top_control;
    private RelativeLayout rv_choose_caller;
    private LinearLayout ll_invitation;
    private RelativeLayout rv_close_voice_all;
    private CustomPopWindow mCustomPopWindow;
    private CustomPopWindow sharePopWindow;
    private CustomPopWindow mViewerMore;

    private static final String[] CHANNELS = new String[]{"最近通话", "通讯录", "复制链接"};
    private List<String> mDataList = Arrays.asList(CHANNELS);
    private CustomScrollViewPager mViewPager;
    private List<Fragment> mFragments = new ArrayList<Fragment>();
    private MagicIndicator magicIndicator;
    private MyAdapter myAdapter;


    private List<String> strDataList = new ArrayList<>();
    private CustomScrollViewPager viewViewPager;
    private List<Fragment> mViewFragments = new ArrayList<Fragment>();
    private MagicIndicator viewMagicIndicator;
    private viewAdapter viewAdapter;
    private TextView tv_more;
    private TextView tv_close_voice_all;
    private int roomId;
    private boolean bFirstBackPress = true;
    private boolean bFrontCamera = true, bMicEnable = true;
    //画板数据
    private String mWhiteboard = "";
    private String mType = "";//画板状态
    private String shareImages = "1";//当type=1 传递图片元数据 | type=2 传递左右录播手势数据
    private int isOpen = 0;//1：允许 0：静音
    private int muteType = 1;//1：允许.. 2:禁止.. \参会者自己解除静音
    private int uId = 0;//要踢的用户ID
    private LinkedHashMap hashMap = new LinkedHashMap();
    private SketchpadView white_board;
    //    private DrawBoardView white_board;
    private RadioGroup radio_group_colors, rg_paint_tools;
    private ImageView iv_invisible;
    private LinearLayout ll_color_list;
    private RelativeLayout rl_white_board_layout;
    private List<LocalMedia> selectList = new ArrayList<>();
    private List<String> imagePath = new ArrayList<>();
    private Banner iv_banner;

    private Realm realm;
    private boolean IsShareImages = false;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        SocketUtil.getInstance();
        SocketUtil.getInstance().setSocketDataCallback(this);
        // 初始化UI
        initView();
        //        new DrawBoardAction("10.131.4.118", 9090).start();
        // 添加事件监听回调
        ILiveSDK.getInstance().addEventHandler(eventHandler);
        realm = Realm.getDefaultInstance();
        Intent intent = getIntent();
        if (null != intent) {
            roomId = Integer.valueOf(intent.getStringExtra("roomId"));
            if (0 != roomId) {
                //                Log.i("进入的房间号", roomId + "");
                enterTrtcRoom(roomId);
                tvRoomId.setText("" + roomId);
                meetingInfo();
                infoMeeting();
            }
        }
        timer.start();

    }

    private void showPopMenu() {
        View contentView = LayoutInflater.from(this).inflate(R.layout.pop_room_menu_more, null);
        //处理popWindow 显示内容
        handleLogic(contentView);
        //创建并显示popWindow
        mCustomPopWindow = new CustomPopWindow.PopupWindowBuilder(this)
                .setView(contentView)
                .create();
        mCustomPopWindow.showAsDropDown(ll_control, DensityUtils.dp2px(this, 5), -(ll_control.getHeight() + mCustomPopWindow.getHeight()));
    }

    /**
     * 处理弹出显示内容、点击事件等逻辑
     *
     * @param contentView
     */
    private void handleLogic(View contentView) {
        View.OnClickListener listener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mCustomPopWindow != null) {
                    mCustomPopWindow.dissmiss();
                }
                String showContent = "";
                switch (v.getId()) {
                    case R.id.tv_keyboard:
                        showContent = RoomActivity.this.getResources().getString(R.string.app_scan_code);
                        break;
                    case R.id.tv_invitation_call:
                        ll_invitation.setVisibility(View.VISIBLE);
                        ll_control.setVisibility(View.INVISIBLE);
                        return;
                    case R.id.tv_start_recode:
                        showContent = RoomActivity.this.getResources().getString(R.string.app_scan_code);
                        break;
                    case R.id.tv_voice_modem:
                        showContent = RoomActivity.this.getResources().getString(R.string.app_share_load_link);
                        break;
                    case R.id.tv_close_pip:
                        showContent = RoomActivity.this.getResources().getString(R.string.app_share_load_link);
                        break;
                }
                timer.cancel();
                timer.start();

                Toast.makeText(RoomActivity.this, showContent, Toast.LENGTH_SHORT).show();
            }
        };
        contentView.findViewById(R.id.tv_keyboard).setOnClickListener(listener);
        contentView.findViewById(R.id.tv_invitation_call).setOnClickListener(listener);
        contentView.findViewById(R.id.tv_start_recode).setOnClickListener(listener);
        contentView.findViewById(R.id.tv_voice_modem).setOnClickListener(listener);
        contentView.findViewById(R.id.tv_close_pip).setOnClickListener(listener);

    }

    private void showSharePopMenu() {
        View shareView = LayoutInflater.from(this).inflate(R.layout.pop_room_menu_share, null);
        //处理popWindow 显示内容
        handleShareLogic(shareView);
        //创建并显示popWindow
        sharePopWindow = new CustomPopWindow.PopupWindowBuilder(this)
                .setView(shareView)
                .create();
        sharePopWindow.showAsDropDown(ll_control, DensityUtils.dp2px(this, ll_control.getWidth() - sharePopWindow.getWidth()) / 2, -(ll_control.getHeight() + sharePopWindow.getHeight()));
    }

    /**
     * 分享图片，打开白板，截图
     *
     * @param contentView
     */
    private void handleShareLogic(View contentView) {
        View.OnClickListener listener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (sharePopWindow != null) {
                    sharePopWindow.dissmiss();
                }
                String showContent = "";
                switch (v.getId()) {
                    case R.id.tv_share_img:
                        if (!IsShareImages) {
                            IsShareImages = true;
                            shareImages();
                        } else {
                            shareImages("0", 1);
                            IsShareImages = false;
                            iv_banner.setVisibility(View.INVISIBLE);
                        }
                        break;
                    case R.id.tv_open_white_board:
                        if (rl_white_board_layout.getVisibility() == View.INVISIBLE) {
                            rl_white_board_layout.setVisibility(View.VISIBLE);
                            ((TextView) contentView.findViewById(R.id.tv_open_white_board)).setText("关闭白板");
                        } else {
                            ((TextView) contentView.findViewById(R.id.tv_open_white_board)).setText("打开白板");
                            rl_white_board_layout.setVisibility(View.INVISIBLE);
                        }
                        break;
                    case R.id.tv_screen_shots:
                        showContent = RoomActivity.this.getResources().getString(R.string.app_scan_code);
                        break;
                }
                timer.cancel();
                timer.start();
                Toast.makeText(RoomActivity.this, showContent, Toast.LENGTH_SHORT).show();
            }
        };
        contentView.findViewById(R.id.tv_share_img).setOnClickListener(listener);
        contentView.findViewById(R.id.tv_open_white_board).setOnClickListener(listener);
        contentView.findViewById(R.id.tv_screen_shots).setOnClickListener(listener);

    }

    private void showViewerMorePopMenu() {
        View viewerMore = LayoutInflater.from(this).inflate(R.layout.pop_room_menu_viewer_more, null);
        //处理popWindow 显示内容
        handlevViewerMoreLogic(viewerMore);
        //创建并显示popWindow
        mViewerMore = new CustomPopWindow.PopupWindowBuilder(this)
                .setView(viewerMore)
                .create();
        //        mViewerMore.showAsDropDown(tv_more, DensityUtils.dp2px(this, tv_more.getWidth() - mViewerMore.getWidth()) / 2, 10);
        mViewerMore.showAtLocation(rv_close_voice_all, Gravity.BOTTOM, DensityUtils.getScreenWidth(RoomActivity.this) - 20, 10);
    }

    /**
     * 参与者更多pop
     *
     * @param contentView
     */
    private void handlevViewerMoreLogic(View contentView) {
        View.OnClickListener listener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (v.getId()) {
                    case R.id.tv_call_names:
                        hostCallNames();
                        break;
                    case R.id.tv_quit_room:
                        ILiveRoomManager.getInstance().quitRoom();
                        break;
                    case R.id.tv_cancel:
                        break;
                }
                if (mViewerMore != null) {
                    mViewerMore.dissmiss();
                }
            }
        };
        contentView.findViewById(R.id.tv_call_names).setOnClickListener(listener);
        contentView.findViewById(R.id.tv_quit_room).setOnClickListener(listener);
        contentView.findViewById(R.id.tv_cancel).setOnClickListener(listener);

    }

    private Context getContext() {
        return isFinishing() ? null : this;
    }

    //////////////////////////////////    TRTC主要流程   ////////////////////////////////////////

    /**
     * 加入音视频房间
     */
    private void enterTrtcRoom(int roomId) {
        // Step 3: 设置渲染控件
        ILiveRoomManager.getInstance().initAvRootView(avRootView);
        customRootView(avRootView);     // 定制渲染控件

        ILiveRoomOption option = new ILiveRoomOption()
                .imsupport(true)       // 需要IM功能
                .exceptionListener(this)  // 监听异常事件处理
                .roomDisconnectListener(this)   // 监听房间中断事件
                .controlRole("ed960")  // 使用user角色
                .autoCamera(true)       // 进房间后不需要打开摄像头
                .autoMic(true);         // 进房间后不需打开Mic
        // Step 4: 加入音视频房间
        if (roomId == sharedPreferences.getInt(AppConstant.ROOM_ID, 0)) {
            ILiveRoomManager.getInstance().createRoom(roomId, option);
            Log.i("enterTrtcRoom", "创建房间");
        } else {
            ILiveRoomManager.getInstance().joinRoom(roomId, option);
            Log.i("enterTrtcRoom", "加入房间");
        }
    }

    /**
     * 处理TRTC 事件
     */
    private ILiveEventHandler eventHandler = new ILiveEventHandler() {
        @Override
        public void onForceOffline(String userId, String module, int errCode, String errMsg) {
            DlgMgr.showMsg(getContext(), "帐号被踢下线: " + module + "|" + errCode + "|" + errMsg);
            finish();
        }

        @Override
        public void onCreateRoomSuccess(int roomId, String groupId) {
            DlgMgr.showToast(getContext(), "创建房间成功");
        }

        @Override
        public void onCreateRoomFailed(int roomId, String module, int errCode, String errMsg) {
            DlgMgr.showMsg(getContext(), "创建房间失败: " + module + "|" + errCode + "|" + errMsg);
        }

        @Override
        public void onJoinRoomSuccess(int roomId, String groupId) {
            DlgMgr.showToast(getContext(), "加入房间成功");
        }

        @Override
        public void onJoinRoomFailed(int roomId, String module, int errCode, String errMsg) {
            if (module.equals(ILiveConstants.Module_IMSDK) && (10010 == errCode || 10015 == errCode)) {
                ILiveRoomManager.getInstance().createRoom(roomId, new ILiveRoomOption()
                        .controlRole("user"));
            } else {
                DlgMgr.showMsg(getContext(), "加入房间失败: " + module + "|" + errCode + "|" + errMsg);
            }
        }

        @Override
        public void onQuitRoomSuccess(int roomId, String groupId) {
            finish();
        }

        @Override
        public void onQuitRoomFailed(int roomId, String module, int errCode, String errMsg) {
            DlgMgr.showMsg(getContext(), "退出房间失败: " + module + "|" + errCode + "|" + errMsg);
        }
    };

    //////////////////////////////////    UI处理   ////////////////////////////////////////

    @Override
    protected void onResume() {
        super.onResume();
        //注册EventBus，首先判断是否进行了注册，如果没有注册则添加注册
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
        ILiveRoomManager.getInstance().onResume();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        DrawBoardAction.close();
        ILiveSDK.getInstance().clearEventHandler();

    }

    @Override
    public void onBackPressed() {
        if (bFirstBackPress) {
            bFirstBackPress = false;
            if (ILiveRoomManager.getInstance() != null) {
                meetingLeave();
                //                if (ILiveLoginManager.getInstance().isLogin()) {
                ////                    ILiveLoginManager.getInstance().iLiveLogout();
                ////                }
                //                ILiveRoomManager.getInstance().quitRoom();
                ILiveRoomManager.getInstance().onDestory();
            }
        } else {
            finish();
        }
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.ll_switch) {
            bFrontCamera = !bFrontCamera;
            ILiveRoomManager.getInstance().switchCamera(bFrontCamera ? ILiveConstants.FRONT_CAMERA : ILiveConstants.BACK_CAMERA);
            ivSwitch.setImageResource(bFrontCamera ? R.drawable.icon_change_camera : R.drawable.icon_change_camera);
        } else if (v.getId() == R.id.ll_voice) {
            bMicEnable = !bMicEnable;
            userEnableMic(bMicEnable);
            timer.cancel();
            timer.start();
            ivMic.setImageResource(bMicEnable ? R.drawable.mic : R.drawable.mic2);
            showToast("meeting@mic");
            meetingMic();
        } else if (v.getId() == R.id.ll_views) {
            rv_close_voice_all.setVisibility(View.VISIBLE);
            timer.cancel();
            timer.start();
        } else if (v.getId() == R.id.ll_share) {
            showSharePopMenu();
            timer.cancel();
            timer.start();
        } else if (v.getId() == R.id.ll_video) {
            meetingCamera();
            timer.cancel();
            timer.start();
        } else if (v.getId() == R.id.ll_more) {
            showPopMenu();
            timer.cancel();
            timer.start();
        } else if (v.getId() == R.id.tv_more) {
            showViewerMorePopMenu();
        } else if (v.getId() == R.id.tv_close_voice_all) {
            showToast("全体静音");
            meetingMute();
        }
        if (v.getId() == R.id.iv_hang_up) {
            ILiveRoomManager.getInstance().quitRoom();
        }
        if (v.getId() == R.id.iv_invisible) {//画笔颜色切换,返回
            ll_color_list.setVisibility(View.INVISIBLE);
            rg_paint_tools.setVisibility(View.VISIBLE);
        }
    }

    private LinearLayout initClickableLayout(int resId) {
        LinearLayout layout = (LinearLayout) findViewById(resId);
        layout.setOnClickListener(this);
        return layout;
    }

    private void initView() {
        setContentView(R.layout.room_activity);
        avRootView = (AVRootView) findViewById(R.id.av_root_view);
        tvRoomId = (TextView) findViewById(R.id.tv_room_id);
        initClickableLayout(R.id.ll_views);
        initClickableLayout(R.id.ll_switch);
        initClickableLayout(R.id.ll_share);
        initClickableLayout(R.id.ll_voice);
        initClickableLayout(R.id.ll_more);
        rl_top_control = findViewById(R.id.rl_top_control);
        rv_choose_caller = findViewById(R.id.rv_choose_caller);
        ll_invitation = findViewById(R.id.ll_invitation);
        rv_close_voice_all = findViewById(R.id.rv_close_voice_all);
        ll_control = initClickableLayout(R.id.ll_control);
        initClickableLayout(R.id.ll_video);
        //        initClickableLayout(R.id.ll_feedback);
        ivSwitch = (ImageView) findViewById(R.id.iv_switch);
        ivBeauty = (ImageView) findViewById(R.id.iv_views);
        ivMic = (ImageView) findViewById(R.id.iv_mic);
        iv_hang_up = (ImageView) findViewById(R.id.iv_hang_up);
        iv_hang_up.setOnClickListener(this);

        mViewPager = (CustomScrollViewPager) findViewById(R.id.view_pager);
        initFragments();
        myAdapter = new MyAdapter(getSupportFragmentManager(), mFragments);
        initMagicIndicator();
        mViewPager.setScrollable(true);
        mViewPager.setAdapter(myAdapter);

        tv_more = findViewById(R.id.tv_more);
        tv_close_voice_all = findViewById(R.id.tv_close_voice_all);
        tv_more.setOnClickListener(this);
        tv_close_voice_all.setOnClickListener(this);
        strDataList.add("已入会");
        strDataList.add("举手");
        viewViewPager = (CustomScrollViewPager) findViewById(R.id.view_pager_all);
        initViewFragments();
        viewAdapter = new viewAdapter(getSupportFragmentManager(), mViewFragments);
        initViewMagicIndicator();
        viewViewPager.setScrollable(true);
        viewViewPager.setAdapter(viewAdapter);

        ll_color_list = (LinearLayout) findViewById(R.id.ll_color_list);

        rl_white_board_layout = findViewById(R.id.rl_white_board_layout);

        white_board = findViewById(R.id.sketchad_view);
        white_board.setShowToolsbar(this);

        radio_group_colors = findViewById(R.id.radio_group_colors);
        radio_group_colors.setOnCheckedChangeListener(this);
        rg_paint_tools = findViewById(R.id.rg_paint_tools);
        rg_paint_tools.setOnCheckedChangeListener(this);

        //        white_board.paint.setXfermode(null);        //取消擦除效果
        //        white_board.paint.setStrokeWidth(5);        //初始化画笔的宽度

        iv_invisible = findViewById(R.id.iv_invisible);
        iv_invisible.setOnClickListener(this);

        iv_banner = (Banner) findViewById(R.id.iv_banner);
        iv_banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR);
        iv_banner.setIndicatorGravity(BannerConfig.CENTER);
        iv_banner.setVisibility(View.INVISIBLE);
        iv_banner.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int i, float v, int i1) {

            }

            @Override
            public void onPageSelected(int i) {
                showToast("当前选择的" + i);
                shareImages("2", i);
            }

            @Override
            public void onPageScrollStateChanged(int i) {

            }
        });

    }


    private void initFragments() {
        RecentCallFragment recentCallFragment = new RecentCallFragment();
        mFragments.add(recentCallFragment);
        ContactsFragment completedMeetingFragment = new ContactsFragment();
        mFragments.add(completedMeetingFragment);
        CopyLinkFragment copyLinkFragment = new CopyLinkFragment();
        mFragments.add(copyLinkFragment);

    }

    @SuppressLint("ResourceAsColor")
    private void initMagicIndicator() {
        magicIndicator = findViewById(R.id.magic_indicator);
        magicIndicator.setBackgroundColor(R.color.colorBg);
        CommonNavigator commonNavigator = new CommonNavigator(getContext());
        commonNavigator.setAdjustMode(true);
        commonNavigator.setAdapter(new CommonNavigatorAdapter() {
            @Override
            public int getCount() {
                return mDataList.size();
            }

            @Override
            public IPagerTitleView getTitleView(Context context, final int i) {
                SimplePagerTitleView simplePagerTitleView = new ColorTransitionPagerTitleView(context);
                simplePagerTitleView.setText(mDataList.get(i));
                simplePagerTitleView.setNormalColor(Color.WHITE);
                simplePagerTitleView.setSelectedColor(Color.parseColor("#FF42ADFF"));
                simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        mViewPager.setCurrentItem(i);
                        if (i == 2) {
                            rv_choose_caller.setVisibility(View.INVISIBLE);
                        } else {
                            rv_choose_caller.setVisibility(View.VISIBLE);
                        }
                    }
                });
                return simplePagerTitleView;
            }

            @Override
            public IPagerIndicator getIndicator(Context context) {
                LinePagerIndicator indicator = new LinePagerIndicator(context);
                indicator.setStartInterpolator(new AccelerateInterpolator());
                indicator.setEndInterpolator(new DecelerateInterpolator(1.6f));
                indicator.setYOffset(UIUtil.dip2px(context, 0));
                indicator.setLineHeight(UIUtil.dip2px(context, 1));
                indicator.setColors(Color.parseColor("#FF42ADFF"));
                return indicator;
            }
        });
        magicIndicator.setNavigator(commonNavigator);
        ViewPagerHelper.bind(magicIndicator, mViewPager);

    }

    private void initViewFragments() {
        InitiationFragment initiationFragment = new InitiationFragment();
        mViewFragments.add(initiationFragment);
        HandsupFragment handsupFragment = new HandsupFragment();
        mViewFragments.add(handsupFragment);

    }


    private CommonNavigatorAdapter commonNavigatorAdapter = new CommonNavigatorAdapter() {
        @Override
        public int getCount() {
            return strDataList.size();
        }

        @Override
        public IPagerTitleView getTitleView(Context context, final int i) {
            SimplePagerTitleView simplePagerTitleView = new ColorTransitionPagerTitleView(context);
            simplePagerTitleView.setText(strDataList.get(i));
            simplePagerTitleView.setNormalColor(Color.WHITE);
            simplePagerTitleView.setSelectedColor(Color.parseColor("#FF42ADFF"));
            simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    viewViewPager.setCurrentItem(i);
                }
            });
            return simplePagerTitleView;
        }

        @Override
        public IPagerIndicator getIndicator(Context context) {
            LinePagerIndicator indicator = new LinePagerIndicator(context);
            indicator.setStartInterpolator(new AccelerateInterpolator());
            indicator.setEndInterpolator(new DecelerateInterpolator(1.6f));
            indicator.setYOffset(UIUtil.dip2px(context, 0));
            indicator.setLineHeight(UIUtil.dip2px(context, 1));
            indicator.setColors(Color.parseColor("#FF42ADFF"));
            return indicator;
        }
    };

    @SuppressLint("ResourceAsColor")
    private void initViewMagicIndicator() {
        viewMagicIndicator = findViewById(R.id.magic_indicator_all);
        viewMagicIndicator.setBackgroundColor(R.color.colorBg);
        CommonNavigator commonNavigator = new CommonNavigator(getContext());
        commonNavigator.setAdjustMode(false);
        commonNavigator.setAdapter(commonNavigatorAdapter);
        viewMagicIndicator.setNavigator(commonNavigator);
        ViewPagerHelper.bind(viewMagicIndicator, viewViewPager);

    }

    //////////////////////////////////    渲染定制   ////////////////////////////////////////

    private void customRootView(final AVRootView rootView) {

        rootView.setGravity(AVRootView.LAYOUT_GRAVITY_RIGHT);     // 右侧展示小窗口
        rootView.setBackground(R.drawable.com_bg);                  // 设置背景图片
        //        rootView.setDeviceRotation(90);
        //        rootView.setLocalRotationFix(90);
        //        rootView.setRemoteRotationFix(90);
        rootView.setLocalFullScreen(true);
        rootView.setAutoOrientation(true);
        rootView.setSubCreatedListener(new AVRootView.onSubViewCreatedListener() {
            @Override
            public void onSubViewCreated() {
                for (int i = 0; i < ILiveConstants.MAX_AV_VIDEO_NUM; i++) {
                    final int index = i;
                    final AVVideoView videoView = rootView.getViewByIndex(i);
                    if (i != 0) {
                        videoView.setDragable(true);
                    }
                    // 可拖动
                    videoView.setGestureListener(new GestureDetector.SimpleOnGestureListener() {
                        @Override
                        public boolean onSingleTapConfirmed(MotionEvent e) {        // 小屏点击交换
                            if (index == 0) {
                                Log.e("111111111111111111", "小屏点击交换 index ==" + (ll_control.getVisibility() == View.INVISIBLE));
                                if (ll_control.getVisibility() == View.INVISIBLE) {
                                    ll_control.setVisibility(View.VISIBLE);
                                    rl_top_control.setVisibility(View.VISIBLE);
                                    timer.start();
                                }
                                if (ll_invitation.getVisibility() == View.VISIBLE) {
                                    ll_invitation.setVisibility(View.INVISIBLE);
                                }
                                if (rv_close_voice_all.getVisibility() == View.INVISIBLE) {
                                    ll_control.setVisibility(View.VISIBLE);
                                    rl_top_control.setVisibility(View.VISIBLE);
                                    timer.start();
                                }
                                if (rv_close_voice_all.getVisibility() == View.VISIBLE) {
                                    rv_close_voice_all.setVisibility(View.INVISIBLE);
                                }
                            } else {
                                rootView.swapVideoView(0, index);
                            }
                            return super.onSingleTapConfirmed(e);
                        }
                    });
                }

            }
        });
    }


    public void shareImages() {
        token(realm);
        shareImages("0", 1);
        PictureSelector.create(this)
                .openGallery(PictureMimeType.ofImage())
                .theme(R.style.picture_default_style)// 主题样式设置 具体参考 values/styles   用法：R.style.picture.white.style
                .maxSelectNum(9)// 最大图片选择数量
                //                .minSelectNum(1)// 最小选择数量
                //                .imageSpanCount(4)// 每行显示个数
                .selectionMode(PictureConfig.MULTIPLE)
                .previewImage(true)// 是否可预览图片
                .isCamera(false)// 是否显示拍照按钮
                .isZoomAnim(true)// 图片列表点击 缩放效果 默认true
                .enableCrop(false)// 是否裁剪
                .compress(true)// 是否压缩
                .synOrAsy(false)//同步true或异步false 压缩 默认同步
                //.compressSavePath(getPath())//压缩图片保存地址
                .glideOverride(100, 100)// glide 加载宽高，越小图片列表越流畅，但会影响列表图片浏览的清晰度
                .isGif(false)// 是否显示gif图片
                .openClickSound(false)// 是否开启点击声音
                .selectionMedia(selectList)// 是否传入已选图片
                //.previewEggs(false)// 预览图片时 是否增强左右滑动图片体验(图片滑动一半即可看到上一张是否选中)
                //.cropCompressQuality(90)// 裁剪压缩质量 默认100
                .minimumCompressSize(100)// 小于100kb的图片不压缩
                .forResult(PictureConfig.CHOOSE_REQUEST);//结果回调onActivityResult code
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            switch (requestCode) {
                case PictureConfig.CHOOSE_REQUEST:
                    // 图片选择结果回调
                    selectList = PictureSelector.obtainMultipleResult(data);
                    // 例如 LocalMedia 里面返回三种path
                    // 1.media.getPath(); 为原图path
                    // 2.media.getCutPath();为裁剪后path，需判断media.isCut();是否为true
                    // 3.media.getCompressPath();为压缩后path，需判断media.isCompressed();是否为true
                    // 如果裁剪并压缩了，已取压缩路径为准，因为是先裁剪后压缩的

                    for (LocalMedia media : selectList) {
                        Log.i("图片-----》", media.getPath());
                        imagePath.add(media.getPath());
                    }
                    Log.i("图片数量==", imagePath.size() + "");
                    iv_banner.setVisibility(View.VISIBLE);
                    iv_banner.setImages(imagePath)
                            .isAutoPlay(false)
                            .setImageLoader(new CGlideImageLoader()).start();
                    formUpload(selectList);
                    break;
            }
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        //取消注册，如果已经注册了，则取消注册
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
        ILiveRoomManager.getInstance().onPause();
    }


    CountDownTimer timer = new CountDownTimer(5000, 10) {
        @Override
        public void onTick(long millisUntilFinished) {
        }

        @Override
        public void onFinish() {
            rl_top_control.setVisibility(View.INVISIBLE);
            //            ll_control.setVisibility(View.INVISIBLE);
            if (sharePopWindow != null) {
                sharePopWindow.dissmiss();
            }
            if (mCustomPopWindow != null) {
                mCustomPopWindow.dissmiss();
            }
        }
    };

    //////////////////////////////////    视频信息    ////////////////////////////////////////

    private Runnable infoRun = new Runnable() {
        @Override
        public void run() {
            //            if (!bLogEnable)
            //                return;
            ILiveQualityData qualityData = ILiveRoomManager.getInstance().getQualityData();
            if (null != qualityData) {
                RoomTipsInfo tipInfo = new RoomTipsInfo(((AVRoomMulti) ILiveSDK.getInstance().getContextEngine().getRoomObj()).getQualityTips());
                String info = "发送速率:\t" + qualityData.getSendKbps() + "kbps\t"
                        + "丢包率:\t" + qualityData.getSendLossRate() / 100 + "%\n"
                        + "接收速率:\t" + qualityData.getRecvKbps() + "kbps\t"
                        + "丢包率:\t" + qualityData.getRecvLossRate() / 100 + "%\n"
                        + "应用CPU:\t" + qualityData.getAppCPURate() + "%\t"
                        + "系统CPU:\t" + qualityData.getSysCPURate() + "%\n";

                info += "角色: " + tipInfo.getCurRole() + "\n";
                info += "SDKAPPID: " + ILiveSDK.getInstance().getAppId() + "\nVersion:" + ILiveSDK.getInstance().getVersion();
                Log.d("Runnable==", "run: " + info);
                //                ((TextView) findViewById(R.id.tv_status)).setText(info);
            }
            ILiveSDK.getInstance().runOnMainThread(this, 2000);
        }
    };


    @Override
    public void onException(int exceptionId, int errCode, String errMsg) {

    }

    @Override
    public void onRoomDisconnect(int errCode, String errMsg) {

    }

    @Override
    public void sendMessage(String msg) {
        strDataList.set(0, msg);
        commonNavigatorAdapter.notifyDataSetChanged();
    }

    @Override
    public void handsupMessage(String msg) {
        strDataList.set(1, msg);
        commonNavigatorAdapter.notifyDataSetChanged();
    }

    @Subscribe
    public void onEvent(final BoardEvent event) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {
                    Object object = event.getObject();
                    switch (event.what) {
                        case EventConfig.POINT:
                            DrawBoardPoint point = (DrawBoardPoint) object;
                            handlePoint(point);
                            break;
                        case EventConfig.COMMAND:
                            Command command = (Command) object;
                            handleCommand(command);
                            break;
                        case EventConfig.COLOR:
                            SelectColor color = (SelectColor) object;
                            handleColor(color);
                            break;
                        case EventConfig.STROKE:
                            StrokeWidth strokeWidth = (StrokeWidth) object;
                            handleStroke(strokeWidth);
                            break;
                    }
                } catch (Exception e) {
                    Log.e("onEvent", "handle board event fail");
                }

            }
        });
    }

    private void handleStroke(StrokeWidth strokeWidth) {
        int type = strokeWidth.getType();
        int width = strokeWidth.getStroke();
        switch (type) {
            case SketchpadView.STROKE_PEN:
                SketchpadView.setStrokeSize(width, SketchpadView.STROKE_PEN);
                break;
            case SketchpadView.STROKE_ERASER:
                SketchpadView.setStrokeSize(width, SketchpadView.STROKE_ERASER);
                break;
        }
    }


    private void handlePoint(DrawBoardPoint point) {
        int x = point.getX();
        int y = point.getY();
        switch (point.getState()) {
            case SketchpadView.ACTION_DOWN:
                white_board.action_down(x, y);
                break;
            case SketchpadView.ACTION_MOVE:
                white_board.action_move(x, y);
                break;
            case SketchpadView.ACTION_UP:
                white_board.action_up(x, y);
                break;
        }
    }

    private void handleCommand(Command command) {
        switch (command.getType()) {
            case SketchpadView.UNDO:
                white_board.undo();
                break;
            case SketchpadView.REDO:
                white_board.redo();
                break;
            case SketchpadView.CLEAR_BOARD:
                white_board.clearAllStrokes();
                break;
            default:
                white_board.setStrokeType(command.getType());
                break;
        }
    }

    private void handleColor(SelectColor color) {
        int rgb = Color.rgb(color.getR(), color.getG(), color.getB());
        white_board.setStrokeColor(rgb);
    }

    @Override
    public void socketDataCallback(int code, JSONObject jsonObject) {
        //        showToast("socketDataCallback" + code);
        Log.i("room_socketDataCall", code + "");
        switch (code) {
            case AppConstant.MESSAGE_EVENT_ID_USER_CACHE_SUCCESS:
                break;
            case AppConstant.MESSAGE_EVENT_ID_USER_CAMERA_OPEN:
                userEnableCamera(ILiveRoomManager.getInstance().getActiveCameraId(), true);
                break;
            case AppConstant.MESSAGE_EVENT_ID_USER_CAMERA_CLOSE:
                userEnableCamera(ILiveRoomManager.getInstance().getActiveCameraId(), false);
                break;
            case AppConstant.MESSAGE_EVENT_ID_USER_MIC_OPEN:
                userEnableMic(true);
                break;
            case AppConstant.MESSAGE_EVENT_ID_USER_MIC_CLOSE:
                userEnableMic(false);
                break;
            case AppConstant.MESSAGE_EVENT_ID_USER_ALL_MUTE_1:
                userEnableMic(false);
                break;
            case AppConstant.MESSAGE_EVENT_ID_USER_ALL_MUTE_2:
                userEnableMic(false);
                break;
            case AppConstant.MESSAGE_EVENT_ID_MEETING_ROLLCALL_RECEIVE:

                break;
            case AppConstant.MESSAGE_EVENT_ID_MEETING_KICK_USER:

                break;
            case AppConstant.MESSAGE_EVENT_ID_MEETING_MAIN_ID:
                Log.i("MEETING_ROLLCALL_RE", code + "");
                break;
            case AppConstant.MESSAGE_EVENT_ID_MEETING_ROLL_CALL:
                Log.i("MEETING_ROLLCALL_RE", code + "");
                break;
            case AppConstant.MESSAGE_EVENT_ID_MEETING_DESTROY_ROOM:
                ILiveRoomManager.getInstance().quitRoom();
                break;
            case AppConstant.MESSAGE_EVENT_ID_MEETING_USER_LEAVE:

                break;
            case AppConstant.MESSAGE_EVENT_ID_USER_MIC_HELP:
                Log.i("MEETING_ROLLCALL_RE", code + "");
                break;
            case AppConstant.MESSAGE_EVENT_ID_USER_CHANGE_ROOT:

                break;
            case AppConstant.MESSAGE_EVENT_ID_USER_APPLY_ROOT:
                meetingChange(Integer.valueOf(jsonObject.opt("uid").toString()));
                break;
            case AppConstant.MESSAGE_EVENT_ID_WHITEBOARD_OPEN:
                rl_white_board_layout.setVisibility(View.VISIBLE);
                break;
            case AppConstant.MESSAGE_EVENT_ID_WHITEBOARD_CLOSE:
                rl_white_board_layout.setVisibility(View.INVISIBLE);
                break;
            case AppConstant.MESSAGE_EVENT_ID_WHITEBOARD_DATA:
                shareWhiteboard(0, jsonObject.toString());
                break;
            case AppConstant.MESSAGE_EVENT_ID_IMAGES_OPEN:
                Log.i("显示分享图片", code + "");
                break;
            case AppConstant.MESSAGE_EVENT_ID_IMAGES_CLOSE:
                Log.i("隐藏分享图片", code + "");
                break;
            case AppConstant.MESSAGE_EVENT_ID_IMAGES_EVENT:
                Log.i("分享图片手势", code + "");
                break;
            case AppConstant.MESSAGE_EVENT_ID_SHARE_EVENT_ERROR:
                Log.i("错误事件", code + "");
                break;
        }

    }

    public void formUpload(List<LocalMedia> selectList) {
        ArrayList<File> files = new ArrayList<>();
        if (selectList != null && selectList.size() > 0) {
            for (int i = 0; i < selectList.size(); i++) {
                files.add(new File(selectList.get(i).getPath()));
            }
        }
        //拼接参数
        OkGo.<LzyResponse<String>>post(AppConstant.Url + ComParamContact.Images.PATH)
                .tag(this)
                .headers(ComParamContact.Images.TOKEN, TokenManager.getInstance().getAuthModel().getToken())
                .params(ComParamContact.Images.__TOKEN__, __TOKEN__)
                .params(ComParamContact.Images.ROOM_ID, roomId)
                .isMultipart(true)

                //                .params("file1", new File("文件路径"))   //这种方式为一个key，对应一个文件
                .addFileParams(ComParamContact.Images.IMAGES, files)           // 这种方式为同一个key，上传多个文件
                .execute(new JsonCallback<LzyResponse<String>>() {
                    @Override
                    public void onStart(Request<LzyResponse<String>, ? extends Request> request) {
                        //                        btnFormUpload.setText("正在上传中...");
                    }

                    @Override
                    public void onSuccess(Response<LzyResponse<String>> response) {
                        //                        handleResponse(response);
                        //                        btnFormUpload.setText("上传完成");
                    }

                    @Override
                    public void onError(Response<LzyResponse<String>> response) {
                        //                        handleError(response);
                        //                        btnFormUpload.setText("上传出错");
                    }

                    @Override
                    public void uploadProgress(Progress progress) {
                        System.out.println("uploadProgress: " + progress);
                    }
                });
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        switch (group.getId()) {
            case R.id.radio_group_colors:
                switch (checkedId) {
                    case R.id.radio_color_one:
                        //                        white_board.paint.setColor(Color.RED);    //设置画笔的颜色为红色
                        SketchpadView.setStrokeColor(Color.RED);
                        break;
                    case R.id.radio_color_two:
                        //                        white_board.paint.setColor(Color.YELLOW);    //设置画笔的颜色为红色
                        SketchpadView.setStrokeColor(Color.YELLOW);
                        break;
                    case R.id.radio_color_three:
                        //                        white_board.paint.setColor(Color.BLACK);    //设置画笔的颜色为红色
                        SketchpadView.setStrokeColor(Color.BLACK);
                        break;
                    case R.id.radio_color_four:
                        //                        white_board.paint.setColor(Color.BLUE);    //设置画笔的颜色为红色
                        SketchpadView.setStrokeColor(Color.BLUE);
                        break;
                }
                break;
            case R.id.rg_paint_tools:
                switch (checkedId) {
                    case R.id.rb_thin:
                        //                        white_board.paint.setXfermode(null);        //取消擦除效果
                        //                        white_board.paint.setStrokeWidth(5);    //设置笔触的宽度为5像素
                        SketchpadView.sendDataToPc(DrawBoardData.DataType.STROKE, new StrokeWidth(0, SketchpadView.STROKE_PEN));
                        SketchpadView.setStrokeSize(5, SketchpadView.STROKE_PEN);
                        white_board.setStrokeType(white_board.STROKE_PEN);//设置画笔的类型
                        break;
                    case R.id.rb_paint_thick:
                        //                        white_board.paint.setXfermode(null);        //取消擦除效果
                        //                        white_board.paint.setStrokeWidth(15);    //设置笔触的宽度为15像素
                        SketchpadView.sendDataToPc(DrawBoardData.DataType.STROKE, new StrokeWidth(3, SketchpadView.STROKE_PEN));
                        SketchpadView.setStrokeSize(15, SketchpadView.STROKE_PEN);
                        white_board.setStrokeType(white_board.STROKE_PEN);//设置画笔的类型
                        break;
                    case R.id.rb_clear:
                        //                        white_board.clear();        //橡皮檫
                        //设置橡皮擦的类型
                        white_board.setStrokeType(white_board.STROKE_ERASER);
                        break;
                    case R.id.rb_nothing:
                        //                        white_board.nothing();        //清屏
                        white_board.clearAllStrokes();
                        break;
                    case R.id.rb_color:
                        ll_color_list.setVisibility(View.VISIBLE);
                        rg_paint_tools.setVisibility(View.INVISIBLE);
                        break;
                }
                break;
        }
    }

    @Override
    public void showBar(boolean isShow) {
        if (ll_control.getVisibility() == View.INVISIBLE) {
            ll_control.setVisibility(View.VISIBLE);
            rl_top_control.setVisibility(View.VISIBLE);
            timer.cancel();
            timer.start();
        } else {
            ll_control.setVisibility(View.INVISIBLE);
            rl_top_control.setVisibility(View.INVISIBLE);
            timer.cancel();
        }
    }

    private class MyAdapter extends FragmentStatePagerAdapter {
        private List<Fragment> mFragments;

        public MyAdapter(FragmentManager fm, List<Fragment> mFragments) {
            super(fm);
            this.mFragments = mFragments;
        }

        @Override
        public Fragment getItem(int position) {
            Fragment fragment = null;
            fragment = mFragments.get(position);
            return fragment;
        }

        @Override
        public int getCount() {
            //            Log.e("MyAdapter", mDataList.size() + "");
            return mDataList.size();
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return mDataList.get(position);
        }
    }

    private class viewAdapter extends FragmentStatePagerAdapter {
        private List<Fragment> mFragments;

        public viewAdapter(FragmentManager fm, List<Fragment> mFragments) {
            super(fm);
            this.mFragments = mFragments;
        }

        @Override
        public Fragment getItem(int position) {
            Fragment fragment = null;
            fragment = mFragments.get(position);
            return fragment;
        }

        @Override
        public int getCount() {
            //            Log.e("MyAdapter", mDataList.size() + "");
            return strDataList.size();
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return strDataList.get(position);
        }
    }

    // 摄像头
    public void userEnableCamera(int cameraId, boolean enable) {
        ILiveRoomManager.getInstance().enableCamera(cameraId, enable);
    }

    // 麦克风
    public void userEnableMic(boolean enable) {
        ILiveRoomManager.getInstance().enableMic(enable);
    }

    /**
     * 会议室缓存信息
     */
    public void infoMeeting() {
        OkGo.<String>post(AppConstant.Url + ComParamContact.Info.PATH)
                .params(ComParamContact.Info.TOKEN, TokenManager.getInstance().getAuthModel().getToken())
                .params(ComParamContact.Info.ROOM_ID, roomId)
                .execute(new JsonCallback<String>() {

                    @Override
                    public void onSuccess(Response<String> response) {

                    }

                    @Override
                    public void onError(Response<String> response) {
                        Log.i("onError", response.getException().getMessage());
                    }
                });
    }

    /**
     * 开启/关闭摄像头
     */
    public void meetingCamera() {
        int id = Integer.parseInt(sharedPreferences.getString(AppConstant.USER_ID, ""));
        hashMap.put("room_id", roomId);
        hashMap.put("uid", id);
        hashMap.put("type", isOpen);
        SocketUtil.getInstance().sendSocketData("meeting@camera", hashMap);
        hashMap.clear();
    }


    /**
     * 主持人发起点名
     */
    public void hostCallNames() {
        hashMap.put("room_id", roomId);
        SocketUtil.getInstance().sendSocketData("meeting@rollcall", hashMap);
        hashMap.clear();
    }

    /**
     * 会议人员确认签到
     */
    public void meetingRemain() {
        hashMap.put("room_id", roomId);
        SocketUtil.getInstance().sendSocketData("meeting@remain", hashMap);
        hashMap.clear();
    }

    /**
     * 分享白板事件
     * #0:关闭画板, 1:打开画板, 2:发送画板数据
     */
    public void shareWhiteboard(int mType, String mWhiteboard) {
        hashMap.put("room_id", roomId);
        hashMap.put("type", mType);// 0|1|2, #0:关闭画板, 1:打开画板, 2:发送画板数据
        hashMap.put("data", mWhiteboard);//画板数据  //可选
        SocketUtil.getInstance().sendSocketData("share@whiteboard", hashMap);
        hashMap.clear();
    }

    /**
     * 分享图片事件
     * 'type' => 0|1|2, #0:关闭图片分享, 1:打开图片分享（此功能已转服务端）, 2:操作左右轮播事件
     * 'data' => null  #当type=1 传递图片元数据 | type=2 传递左右录播手势数据
     */
    public void shareImages(String mType, int shareImages) {
        hashMap.put("room_id", roomId);
        hashMap.put("type", mType);// 0|1|2, 0:关闭图片分享, 1:打开图片分享（此功能已转服务端）, 2:操作左右轮播事件
        hashMap.put("data", shareImages);//当type=1 传递图片元数据 | type=2 传递左右录播手势数据
        SocketUtil.getInstance().sendSocketData("share@images", hashMap);
        hashMap.clear();
    }

    /**
     * 主持人授权开麦
     */
    public void meetingMichael() {
        hashMap.put("room_id", roomId);
        hashMap.put("uid", uId);
        hashMap.put("type", isOpen);
        SocketUtil.getInstance().sendSocketData("meeting@michael", hashMap);
        hashMap.clear();
    }

    /**
     * 开启/关闭语音
     */
    public void meetingMic() {
        hashMap.put("room_id", roomId);
        hashMap.put("type", isOpen);
        SocketUtil.getInstance().sendSocketData("meeting@mic", hashMap);
        hashMap.clear();
    }

    /**
     * 主持人发起全体静音
     */
    public void meetingMute() {
        hashMap.put("room_id", roomId);
        hashMap.put("type", muteType);
        SocketUtil.getInstance().sendSocketData("meeting@mute", hashMap);
        hashMap.clear();
    }

    /**
     * 主持踢人
     */
    public void meetingKick(String uId) {
        hashMap.put("room_id", roomId);
        hashMap.put("uid", uId);
        SocketUtil.getInstance().sendSocketData("meeting@kick", hashMap);
        hashMap.clear();
    }

    /**
     * 离开会议房间组
     */
    public void meetingLeave() {
        hashMap.put("room_id", roomId);
        SocketUtil.getInstance().sendSocketData("meeting@leave", hashMap);
        hashMap.clear();
    }

    /**
     * 销毁当前会议组
     */
    public void meetingDestroy() {
        hashMap.put("room_id", roomId);
        SocketUtil.getInstance().sendSocketData("meeting@destroy", hashMap);
        hashMap.clear();
    }

    /**
     * 申请主持人
     */
    public void meetingRoot() {
        hashMap.put("room_id", roomId);
        //        hashMap.put("password", "");
        SocketUtil.getInstance().sendSocketData("meeting@root", hashMap);
        hashMap.clear();
    }

    /**
     * 同步房间信息
     */
    public void meetingInfo() {
        hashMap.put("room_id", roomId);
        SocketUtil.getInstance().sendSocketData("meeting@info", hashMap);
        hashMap.clear();
    }

    /**
     * 当前主持人同意换位
     */
    public void meetingChange(int uid) {
        hashMap.put("room_id", roomId);
        hashMap.put("uid", uid);
        SocketUtil.getInstance().sendSocketData("meeting@change", hashMap);
        hashMap.clear();
    }

}
